import { defineConfig } from 'wxt';

import { EventEmitter } from 'events';

EventEmitter.setMaxListeners(15);

// See https://wxt.dev/api/config.html
export default defineConfig({
  modules: ['@wxt-dev/module-react'],
  manifest() {
    return {
      name: '店小秘批量替换',
      permissions: [
        'storage',
        'contextMenus',
        'unlimitedStorage',
        'cookies',
        'declarativeNetRequest',
        'proxy',
      ],
      host_permissions: [
        'https://*.gigab2b.com/*',
        'https://*.postme.cn/*',
        'https://api.gigacloudlogistics.com/*',
        'https://b2bfiles1.gigab2b.cn/*',
        'https://*.designkit.com/*',
        'https://seller.kuajingmaihuo.com/*',
      ],
      web_accessible_resources: [
        {
          resources: [
            'operation-instruction-html.html',
            'dianxiaomi-meituxiuxiu-html.html',
            'temu-html.html',
          ],
          matches: ['<all_urls>'],
        },
      ],
      declarative_net_request: {
        rule_resources: [
          {
            enabled: true,
            id: 'rules',
            path: 'rules.json',
          },
        ],
      },
      content_security_policy: {
        extension_pages: `script-src 'self' http://localhost:3000; object-src 'self'`,
      },
    };
  },
  vite() {
    return {
      // optimizeDeps: {
      //   esbuildOptions: {
      //     minifySyntax: false,
      //     minifyWhitespace: false,
      //     minifyIdentifiers: false,
      //   },
      // },
    };
  },
});
